//作业1
console.log("作业1")
var str = "A";
for (let i = 0; i < 10; i++)
{
  var s = '';
  for (let j = 0; j < (i+1); j++)
    {
      s += str;
    }
  console.log(s);
}

console.log("-------------------------")
console.log("-------------------------")


//作业2
console.log("作业2")
var str = "A";
for (let i = 10; i > 0; i--)
{
  var s = '';
  for (let j = 0; j < i; j++)
    {
      s += str;
    }
  console.log(s);
}

console.log("-------------------------")
console.log("-------------------------")

//作业3
console.log("作业3")
class PrintChar
{
    constructor(str = "a", raw = 8)
    {
      this.str = str;
      this.raw = raw;
    }

    for1()
    {
      for (let i = 0; i < this.raw; i++)
      {
        var s = '';
        for (let j = 0; j < (i+1); j++)
          {
            s += this.str;
          }
        console.log(s);
      }
    }
    for2()
    {
      for (let i = this.raw; i > 0; i--)
      {
        var s = '';
        for (let j = 0; j < i; j++)
          {
            s += this.str;
          }
        console.log(s);
      }
    }
}
var p = new PrintChar("A", 10);
p.for1();  //第一个作业的结果
console.log("-------------------------")
p.for2();  //第二个作业的结果

console.log("-------------------------")
console.log("-------------------------")

//作业4
console.log("作业4")
var str = "A";
for (let i = 10; i > 0; i--)
{
  var s = '';
  if(i%2 !== 0)
  {
    continue;
  }
  else
  {
    for (let j = 0; j < i; j++)
      {
        s += str;
      }
  }
  console.log(s);
}

console.log("-------------------------")
console.log("-------------------------")

//作业5
console.log("作业5")
function for4(str, raw)
{
  for (let i = 0; i < raw; i++)
  {
    var s = '';
    if(i === 0)
    {
      for (let j = 0; j < (raw-1-i); j++)
        {
          s += ' ';
        }
      s += str;
    }
    else if(i === (raw-1))
    {
      for (let j = 0; j < (2*i+1); j++)
        {
          s += str;
        }
    }
    else
    {
      for (let j = 0; j < (raw-1-i); j++)
        {
          s += ' ';
        }
      s += str;
      for (let j = 0; j < (2*i-1); j++)
        {
          s += ' ';
        }
      s += str;
    }
    console.log(s);
  }
}
for4('A', 8);
